package com.salton123.widget

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
 * User: newSalton@outlook.com
 * Date: 2019-08-11 22:00
 * ModifyTime: 22:00
 * Description:
 */
class HorizontalEvenItemDecoration(private val space: Int) :
    RecyclerView.ItemDecoration() {
    override fun getItemOffsets(
        outRect: Rect, view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) {
        val position = parent.getChildAdapterPosition(view)
        if (position == 0) {
            outRect.left = space
        } else {
            outRect.left = space / 2
        }
        outRect.right = space / 2
    }
}